﻿<UserControl
    x:Class="TfsWorkbench.WpfUI.Controls.TitleControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Controls="clr-namespace:TfsWorkbench.WpfUI.Controls" 
    xmlns:UIElements="clr-namespace:TfsWorkbench.UIElements;assembly=TfsWorkbench.UIElements" 
    mc:Ignorable="d"
    Name="PART_Control"
    >
    <UserControl.Resources>
    	<ResourceDictionary>
    		<ResourceDictionary.MergedDictionaries>
    			<ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/ApplicationStyles.xaml"/>
    		</ResourceDictionary.MergedDictionaries>
            
            <Style x:Key="DisplayModeListStyle" TargetType="{x:Type ListView}">
                <Setter Property="Background" Value="{x:Null}" />
                <Setter Property="BorderThickness" Value="0" />
		        <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                <Setter Property="ItemContainerStyle">
                    <Setter.Value>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ListViewItem}">
                                        <ContentPresenter Content="{TemplateBinding Content}" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListView}">
                            <Border Background="Transparent">
                                <ScrollViewer Padding="{TemplateBinding Padding}">
                                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                </ScrollViewer>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="TitleStack" TargetType="{x:Type StackPanel}">
                <Setter Property="Orientation" Value="Horizontal" />
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="TextBlock.FontSize"  Value="8pt" />
                <Setter Property="Margin" Value="5,0,5,0" />
            </Style>
            
        </ResourceDictionary>
    </UserControl.Resources>
    <ScrollViewer
        VerticalScrollBarVisibility="Disabled"
        HorizontalScrollBarVisibility="Auto">
        <Grid HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Border 
                Margin="5" 
                Effect="{DynamicResource DropShadowLevel1}" 
                Background="{DynamicResource ToolbarBackground}" 
                CornerRadius="5" 
                Padding="5"
                >
                <StackPanel Style="{StaticResource TitleStack}" HorizontalAlignment="Stretch" MinWidth="0">
                    <TextBlock FontSize="14pt" FontWeight="Bold"><Run Text="Mode:"/></TextBlock>
                </StackPanel>
            </Border>

            <ListView 
                Grid.Column="1"
                Name="PART_ItemsControl"
                Style="{DynamicResource DisplayModeListStyle}"
                SelectionChanged="OnItemsControlSelectionChanged"
                >
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <DataTemplate DataType="{x:Type Controls:DisplayModeTitle}">
                        <ContentControl Content="{Binding}" />
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <Border 
                Margin="5" 
                Grid.Column="3" 
                Background="{DynamicResource ToolbarBackground}" 
                CornerRadius="5" 
                Padding="5" 
                Effect="{DynamicResource DropShadowLevel1}"
                >
                <Border.ToolTip>
                    <StackPanel Orientation="Vertical">
                        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <TextBlock FontWeight="Bold" Margin="0,0,4,0"><Run Text="URL:"/></TextBlock>
                            <TextBlock Text="{Binding ProjectData.ProjectCollectionUrl}" Margin="0" />
                        </StackPanel>

                        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <TextBlock FontWeight="Bold" Margin="0,0,4,0"><Run Text="Project:"/></TextBlock>
                            <TextBlock Text="{Binding ProjectData.ProjectName}" />
                        </StackPanel>

                        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <TextBlock FontWeight="Bold" Margin="0,0,4,0"><Run Text="Path:"/></TextBlock>
                            <TextBlock Text="{Binding ProjectData.ProjectIterationPath}" />
                        </StackPanel>

                        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <TextBlock FontWeight="Bold" Margin="0,0,4,0"><Run Text="Area:"/></TextBlock>
                            <TextBlock Text="{Binding ProjectData.ProjectAreaPath}" />
                        </StackPanel>
                    </StackPanel>
                </Border.ToolTip>

                <StackPanel MinWidth="150" Style="{StaticResource TitleStack}" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Vertical">

                    <DockPanel>
                        <Button DockPanel.Dock="Right" Content="Change" Cursor="Hand" Command="{x:Static UIElements:CommandLibrary.LoadProjectCommand}">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <TextBlock> 
                                    <ContentPresenter />
                                    </TextBlock>
                                </ControlTemplate>
                            </Button.Template>
                            <Button.Style>
                                <Style TargetType="Button">
                                    <Setter Property="Foreground" Value="Blue" />
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="true">
                                            <Setter Property="Foreground" Value="Red" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Button.Style>
                        </Button>
                        <TextBlock FontWeight="Bold" Margin="0,0,4,0"><Run Text="Workspace:"/></TextBlock>
                    </DockPanel>

                    <TextBlock HorizontalAlignment="Center">
                    <Run FontWeight="Bold" Text="Iteration: " />
                    <TextBlock Text="{Binding Path=ProjectData.ProjectIterationPath}"/>
                </TextBlock>

                </StackPanel>
            </Border>
        </Grid>
    </ScrollViewer>
</UserControl>
